{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9464146e",
   "metadata": {},
   "source": [
    "## 本周学习内容\n",
    "\n",
    "### 1.课本项目直接运行\n",
    "### 2.认识变量\n",
    "### 3.赋值的概念\n",
    "### 4.python语言基本的数据结构：（文本 ，数值）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "2381c8fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "41"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#回顾上周 模块.tab\n",
    "import datetime\n",
    "datetime.datetime.today().minute"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "912fa064",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "#1.课本项目直接运行\n",
    "#先找到模块，然后从模块中调用一个方法：from模块名字   import模块方法\n",
    "from datetime import datetime\n",
    "  \n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "          21,23,25,27,29,31,33,35,37,39,\n",
    "          41,43,45,47,49,51,53,55,57,59]    \n",
    "  \n",
    "right_this_minute = datetime.today().minute   #当前一直在变化的时间   分钟数\n",
    "  \n",
    "if right_this_minute in odds:\n",
    "    # if语句的子程序会自动空tab键的间隔，如果没有空，不符合语法规则\n",
    "    # if语句子程序不能为空，也就是至少要有一行子程序，如果还不清楚要写子程序，可以使用\n",
    "    #pass\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3cff8b0",
   "metadata": {},
   "source": [
    ">1. 变量的定义\n",
    ">>* **变量** *计算机语言中能储存计算结果或能表示值的抽象概念。变量可以通过变量名访问。 在指令式语言中，变量通常是可变的；但在纯函数式语言（如 Haskell ）中，变量可能是不可变的。 在一些 语言 中，变量可能被明确为是能表示可变状态、具有 存储空间 的抽象（如在 Java 和 Visual Basic 中）；但另外一些语言可能使用其它概念（如 C 的 对象 ）来指称这种抽象，而不严格地定义“变量”的准确外延。\n",
    ">2.变量名称的规范\n",
    ">>1.变量名称只可以用数字字母和下划线来定义\n",
    ">>2.数字不可以作为变量名的开头\n",
    ">>3.内部（开发团队）已经使用过的名称不可以作为变量名\n",
    ">>4.实在想用一个用过的   可以global_zhangzefeng\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "82391e1b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "jack\n"
     ]
    }
   ],
   "source": [
    "# 变量实践1\n",
    "name =\"jack\"\n",
    "print(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "c2c27b10",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "zhang   zefeng\n"
     ]
    }
   ],
   "source": [
    "# 变量实践2\n",
    "first_name=\"zhang\"\n",
    "last_name=\"zefeng\"\n",
    "name=first_name+'   '+last_name\n",
    "print(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "290c4881",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Alex Alex\n",
      "LI,Alex Alex\n"
     ]
    }
   ],
   "source": [
    "#变量实践3\n",
    "name_01 = \"Alex\"\n",
    "name_02 = name_01\n",
    "\n",
    "print(name_01,name_02)\n",
    "\n",
    "name_01 = \"LI,Alex\"\n",
    "\n",
    "print(name_01,name_02)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "61ba06e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 以上结果原因\n",
    "# python是一门解释型语言，是一行一行的执行，没有特殊要求不会重复运行上一行代码的\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a04e540a",
   "metadata": {},
   "source": [
    "[字符串](https://docs.python.org/3/tutorial/introduction.html#strings)\n",
    "       "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "f1544f82",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "doesn't\n"
     ]
    }
   ],
   "source": [
    "# invalid syntax  语法错误\n",
    "phrase=\"doesn't\"\n",
    "print(phrase)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "2a03fd2d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"doesn't\"#解决方案一\n",
    "'doesn\\'t'#解决方案二"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "df0a8e21",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 字符串 三引号\"\"\" \"\"\"或者'''  '''\n",
    "# 三引号 可以用来存储较为复杂的文本数据(例如可以存 其他语言的)\n",
    "\n",
    "广州南方学院_HTML="
   ]
  },
  {
   "cell_type": "markdown",
   "id": "543acfdc",
   "metadata": {},
   "source": [
    "* 字符串可以用加号+运算符来连接，并用 重复"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2130d13",
   "metadata": {},
   "source": [
    "* 字符串可以被索引（下标）\n",
    "> 请大家尝试写下course_name[0] course_name[1] course_name[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "a60c1445",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'interactive-media-production'"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name=\"interactive-media-production\"\n",
    "course_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "3782a9f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'media'"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name[12]+course_name[13]+course_name[14]+course_name[15]+course_name[16]\n",
    "# 尝试取出media"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "07d70807",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'media'"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name[12:17]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "8b5d5dac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'cti'"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name[-5:-2]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "75189138",
   "metadata": {},
   "source": [
    "* 切片(slice)的性质\n",
    "> 1. [值1：值2] 值1<值2\n",
    "> 2. [值1：值2]值2是取不到的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e344172f",
   "metadata": {},
   "source": [
    "* 后面还有，请同学们先自己来尝试练习，自觉决定高度。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "5d18e16a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name.count(\"media\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e30c2efe",
   "metadata": {},
   "source": [
    "### 数值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "87386feb",
   "metadata": {},
   "source": [
    "[数值](https://docs.python.org/3/tutorial/introduction.html#strings)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "9878eeeb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "300"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "100+200"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "72a89272",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "print(type(2021))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "5430219a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'float'>\n"
     ]
    }
   ],
   "source": [
    "print(type(3.1415926))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "ddf574dc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'complex'>\n"
     ]
    }
   ],
   "source": [
    "print(type(3+2j))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "434c6103",
   "metadata": {},
   "source": [
    "### 数值和字符串要分清！！！傻傻分不清楚"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "b3225bd4",
   "metadata": {},
   "outputs": [],
   "source": [
    "a=\"50\"#双引号括起来的是字符串，哪怕里面是数值\n",
    "b=40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "1d24a126",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "can only concatenate str (not \"int\") to str",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-72-ca730b97bf8a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma\u001b[0m\u001b[1;33m+\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str"
     ]
    }
   ],
   "source": [
    "a+b"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "550c608f",
   "metadata": {},
   "source": [
    "### 课后作业（打印当天的课程表）\n",
    "*1.使用time模块获取当天是周几\n",
    "*2.获取周几后，print(\"上午9：45—12：00——xxx课程\")可以尝试打印得好看一点\n",
    ">一定要用if条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fa0be394",
   "metadata": {},
   "outputs": [],
   "source": [
    "weekly\n",
    "周一到周五的课程=\"\"\n",
    "if weekly==1:\n",
    "    print(周一的课成)\n",
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
